<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="./../../template/tagedu.xhtml">

    <ui:define name="title">
        <title><h:outputText value="Carta para os pais - TAG"/></title>
    </ui:define>

    <ui:define name="content">
        <h:outputText styleClass="enrollmentName" value="Carta para os pais"/>
        <h:form id="letterForm">
            <p:messages id="message" autoUpdate="true" showDetail="true"/>
            <h:panelGroup id="details" >
                <div class="input-list">
                <h:outputLabel styleClass="label" for="campaign" value="Campanha: "/>
                <p:selectOneMenu id="campaign" value="#{letterToParentsB.campaign}" converter="campaignC">
                    <f:selectItem value="#{null}" itemLabel="Selecione uma campanha:"/>
                    <f:selectItems value="#{letterToParentsB.campaignList}" var="c" itemLabel="#{c.name}" itemValue="#{c}" />
                        <p:ajax update="bottomCreatePDF organization" process="@this"/>
                </p:selectOneMenu>
                </div>                
                <div class="input-list">
                <h:outputLabel styleClass="label" value="Ano: "/>
                <p:spinner value="#{letterToParentsB.year}" min="#{letterToParentsB.actualYear-1}" max="#{letterToParentsB.actualYear}" size="4">
                    <f:validator validatorId="yearV"/>
                    <f:attribute name="minimo" value="#{(letterToParentsB.actualYear-1).toString()}"/>
                    <f:attribute name="maximo" value="#{(letterToParentsB.actualYear).toString()}"/>
                    <p:ajax update="organization" process="@this"/>  
                </p:spinner>
                </div>
                <div class="input-list">
                <h:outputLabel styleClass="label" for="organization" value="Turma: "/>
                <p:selectOneMenu id="organization" value="#{letterToParentsB.unity}"  converter="unityC"  disabled="#{letterToParentsB.activeUnity()}">
                    <f:selectItem value="#{null}" itemLabel="Selecione uma unidade:"/>
                    <f:selectItems value="#{letterToParentsB.unityList}" var="u" itemLabel="#{u.name}" itemValue="#{u}" />
                    <p:ajax update="bottomCreatePDF" process="@this"/>
                </p:selectOneMenu>
                </div>
                   <p:commandButton id="bottomCreatePDF"   
                                     action="#{letterToParentsB.create()}" 
                                     value="Gerar"   ajax="false" 
                                     onclick="this.form.target='_blank'" disabled="#{letterToParentsB.activeBottom()}"/> 
            </h:panelGroup>   
        </h:form>    
    </ui:define>
</ui:composition>
